Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement FromStr for Path #1480

Merged
merged 15 commits into from
Oct 25, 2021
Merged

Implement FromStr for Path #1480

merged 15 commits into from
Oct 25, 2021

Conversation

seanchen1991
Copy link
Contributor

Closes: #1460

Description

Implements the FromStr trait for Path, along with associated unit tests. This is functionality needed in order to address informalsystems/basecoin-rs#14.


For contributor use:

  • Added a changelog entry, using unclog.
  • If applicable: Unit tests written, added test to CI.
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments.
  • Re-reviewed Files changed in the Github PR explorer.

Copy link
Member

@adizere adizere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Approving, but since Shoaib is the customer for this, I think he should have the final say.

modules/src/ics24_host/path.rs Show resolved Hide resolved
Copy link
Member

@hu55a1n1 hu55a1n1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautifully done @seanchen1991! I added some comments. This is already looking great but I'm also trying to use it with basecoin to see if there is anything we can improve.

modules/src/ics24_host/path.rs Show resolved Hide resolved
modules/src/ics24_host/path.rs Outdated Show resolved Hide resolved
Path::Ports(port_id) => write!(f, "ports/{}", port_id),
Path::Sequences(sequence) => write!(f, "sequences/{}", sequence),
Path::ChannelEnds(port_id, channel_id) => {
write!(f, "channelEnds/ports/{}/channels/{}", port_id, channel_id)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question (@ancazamfir @adizere) - Why do some of our paths diverge from the spec, eg. commitments/ports/{identifier}/channels/{identifier}/sequences/{identifier} v/s spec commitments/ports/{identifier}/channels/{identifier}/packets/{sequence}?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm interesting point, I wasn't aware there's a divergence!

I think the ibc-rs implementation consider as ground truth the ibc-go impl:

https://github.com/cosmos/ibc-go/blob/f7051429e1cf833a6f65d51e6c3df1609290a549/modules/core/24-host/keys.go#L185-L192

which diverges from the spec. It would be worthwhile to highlight this problem in the spec repo.

Copy link
Member

@hu55a1n1 hu55a1n1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Sean! 🙏

@hu55a1n1 hu55a1n1 merged commit a538623 into informalsystems:master Oct 25, 2021
@seanchen1991 seanchen1991 deleted the path-fromstr branch October 25, 2021 15:22
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* Add FromStr<Path> and initial test

* Add `parse_client_type` fn and associated test

* Add `parse_client_paths` fn

* Add `parse_connections` fn

* Add more Path parsing logic

* Complete Path FromStr logic

* Add more Path parsing unit tests

* Add changelog entry

* Fix changelog entry formatting

* Remove stale changelog entry

* Move changelog entry under `ibc` component

* Move Channels and Sequences to a private enum

Co-authored-by: Romain Ruetschi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement FromStr<Path> for ics24_host::Path
4 participants